﻿

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using ly.Model;

namespace Xiangmu
{
    public partial class editUser : System.Web.UI.Page
    {
        ly.BLL.UserInfo user = new ly.BLL.UserInfo();
        ly.Model.UserInfo usermodel = new UserInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string username = Request["UserName"].Trim();
                string strwhere = " where UserName ='" + username+"'";
                DataTable dt = user.GetList(strwhere).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    txtname.Text = dt.Rows[0]["UserName"].ToString().Trim();
                    txtpwd.Text = dt.Rows[0]["Pasword"].ToString().Trim();
                    txtQQ.Text = dt.Rows[0]["QQ"].ToString().Trim();
                    txtemail.Text = dt.Rows[0]["Email"].ToString().Trim();
                    ddltype.Text = dt.Rows[0]["Type"].ToString().Trim();

                }
            }
        }

        protected void lbnedit_Click(object sender, EventArgs e)
        {
            //string name = txtname.Text.Trim();
            usermodel.UserName = Request["UserName"];
            usermodel.Pasword = txtpwd.Text.Trim();
            usermodel.QQ = txtQQ.Text.Trim();
            usermodel.Email = txtemail.Text.Trim();
            usermodel.Type = ddltype.Text.Trim();
            bool flag = user.Update(usermodel);
            if (flag)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功');</script>");
                Response.Redirect("User.aspx");

            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败');</script>");
            }
        }
    }
}